﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

// std headers
#include <memory>
#include <vector>

// qt headers
#include <QObject>

// custom headers
#include "GcsService.h"
#include "IGmepGcsCategory.h"
#include "Major.h"


class QNetworkAccessManager;
class QNetworkRequest;

namespace gmepgcs
{
    template<typename TResult> class CustomReply;
}

namespace gmepgcs
{
    class GCS_SERVICE_EXPORTS ProjectCategoryService : public QObject
    {
        Q_OBJECT

    private:
        explicit ProjectCategoryService();
        ProjectCategoryService(ProjectCategoryService &);
        ProjectCategoryService & operator=(ProjectCategoryService &) = default;
        virtual ~ProjectCategoryService();
    
    public:
        static ProjectCategoryService *Get();

        std::shared_ptr<IGmepGcsCategory> GetCategoryByCode(
            const std::wstring &categoryCode) const;

        /* std::shared_ptr<IGmepGcsCategory> GetCategoryById(
             const std::wstring &categoryId) const;*/

    private:
        void Init();
        void ConfigAuthorization(QNetworkRequest &request) const;

    private:
        static ProjectCategoryService *s_pInstance;
        std::shared_ptr<QNetworkAccessManager> m_spNetworkManager;
        QString m_endPoint;
        std::vector<std::shared_ptr<IGmepGcsCategory>> m_allCategoryList;
    };
}
